
package org.apache.mina.common;

import java.net.SocketAddress;
import java.util.EventListener;

/**
 * Something interested in being notified when the result of an
 * {@link IoService} becomes available.
 * 
 * 当IoService的结果变成可活动时，将通知对此感兴趣的对象。
 */
public interface IoServiceListener extends EventListener {
    /**
     * Invoked when a new service is activated by an {@link IoService}.
     * 
     * 当IoService激活一个新的服务的时候，这个方法会被调用。
     * 
     * @param service
     *            the {@link IoService}
     * @param serviceAddress
     *            the socket address of the {@link IoService} listens to manage
     *            sessions. If the service is an {@link IoAcceptor}, it is a
     *            bind address. If the service is an {@link IoConnector}, it is
     *            a remote address.
     * @param handler
     *            the {@link IoHandler} that serves the new service
     * @param config
     *            the {@link IoServiceConfig} of the new service
     */
    void serviceActivated(IoService service, SocketAddress serviceAddress,
            IoHandler handler, IoServiceConfig config);

    /**
     * Invoked when a service is deactivated by an {@link IoService}.
     * 
     * 当IoService使一个服务无效时，会调用这个方法。
     * 
     * @param service
     *            the {@link IoService}
     * @param serviceAddress
     *            the socket address of the {@link IoService} listens to manage
     *            sessions. If the service is an {@link IoAcceptor}, it is a
     *            bind address. If the service is an {@link IoConnector}, it is
     *            a remote address.
     * @param handler
     *            the {@link IoHandler} that serves the service
     * @param config
     *            the {@link IoServiceConfig} of the service
     */
    void serviceDeactivated(IoService service, SocketAddress serviceAddress,
            IoHandler handler, IoServiceConfig config);

    /**
     * Invoked when a new session is created by an {@link IoService}.
     * 
     * 当IoService创建一个新的会话时，会调用此方法。
     * 
     * @param session
     *            the new session
     */
    void sessionCreated(IoSession session);

    /**
     * Invoked when a session is being destroyed by an {@link IoService}.
     * 
     * 当IoService销毁一个会话时，会调用此方法。
     * 
     * @param session
     *            the session to be destroyed
     */
    void sessionDestroyed(IoSession session);
}
